<template>
  <view>
    <a-button type="primary" @click="test">获取数据</a-button>
    <view v-if="data">数据: {{ data }}</view>
  </view>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';
import axios from '@/utils/request.js';

export default defineComponent({
  setup() {
    const data = ref(null);
    const fetchData = async () => {
      try {
        const response = await axios.get('/api/data');
        data.value = response.data;
      } catch (error) {
        console.error(error);
      }
    };
	const test=()=>{
		alert("123")
	}
    return {
      data,
      fetchData,
	  test
    };
  },
});
</script>